@echo off
REM scripts/health-check.bat

echo 检查服务健康状态...

REM 检查私有仓库
echo 检查私有仓库...
curl -s http://localhost:5000/v2/_catalog >nul 2>&1
if errorlevel 1 (
    echo ✗ 私有仓库: 异常
) else (
    echo ✓ 私有仓库: 正常
)

REM 检查 MySQL
echo 检查 MySQL...
docker-compose exec mysql mysqladmin ping -h localhost -u gd_user -pgd_password >nul 2>&1
if errorlevel 1 (
    echo ✗ MySQL: 异常
) else (
    echo ✓ MySQL: 正常
)

REM 检查 ClickHouse
echo 检查 ClickHouse...
curl -s http://localhost:8123/ping >nul 2>&1
if errorlevel 1 (
    echo ✗ ClickHouse: 异常
) else (
    echo ✓ ClickHouse: 正常
)

REM 检查 Redis
echo 检查 Redis...
docker-compose exec redis redis-cli ping >nul 2>&1
if errorlevel 1 (
    echo ✗ Redis: 异常
) else (
    echo ✓ Redis: 正常
)

REM 检查 Kafka
echo 检查 Kafka...
docker-compose exec kafka kafka-topics --bootstrap-server localhost:9092 --list >nul 2>&1
if errorlevel 1 (
    echo ✗ Kafka: 异常
) else (
    echo ✓ Kafka: 正常
)

REM 检查 Flink
echo 检查 Flink...
curl -s http://localhost:8081/overview >nul 2>&1
if errorlevel 1 (
    echo ✗ Flink: 异常
) else (
    echo ✓ Flink: 正常
)

REM 检查 SpringBoot 应用
echo 检查 SpringBoot 应用...
curl -s http://localhost:8080/api/actuator/health >nul 2>&1
if errorlevel 1 (
    echo ✗ SpringBoot 应用: 异常
) else (
    echo ✓ SpringBoot 应用: 正常
)

echo 健康检查完成
